package com.itzsj.controller;

import com.itzsj.common.result.Result;
import com.itzsj.pojo.dto.ERespondDTO;
import com.itzsj.pojo.dto.EResumesDTO;
import com.itzsj.pojo.entity.Enterprise;
import com.itzsj.pojo.entity.Job;
import com.itzsj.pojo.entity.Message;
import com.itzsj.pojo.vo.EResumesVO;
import com.itzsj.service.EnterpriseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/enterprise")
public class EnterpriseController {

    @Resource
    private EnterpriseService enterpriseService;

    @GetMapping("/get/{eno}")
    public Result get(@PathVariable String eno) {
        log.info("eno {}", eno);
        Enterprise enterprise = enterpriseService.get(eno);
        return Result.success(enterprise);
    }

    @GetMapping("/select/{eno}")
    public Result selectAnnounced(@PathVariable String eno) {
        log.info("eno {}", eno);
        List<Job> jobs = enterpriseService.select(eno);
        return Result.success(jobs);
    }

    @GetMapping("/resume")
    public Result selectResume(EResumesDTO puttedResumeDTO) {
        log.info("puttedResumeDTO {}", puttedResumeDTO);
        List<EResumesVO> resumes = enterpriseService.selectResume(puttedResumeDTO);
        return Result.success(resumes);
    }

    @PostMapping("/announce")
    public Result announce(@RequestBody Job job) {
        log.info("job {}", job);
        enterpriseService.announce(job);
        return Result.success();
    }

    @DeleteMapping("/stop")
    public Result stopAnnounce(String id) {
        enterpriseService.stopAnnounce(id);
        return Result.success();
    }

    @GetMapping("listMsg")
    public Result listMessages(String eno, Integer jobId) {
        List<Message> list = enterpriseService.listMessages(eno, jobId);
        return Result.success(list);
    }

    @PostMapping("/respond")
    public Result respond(@RequestBody ERespondDTO respond) {
        enterpriseService.respond(respond);
        return Result.success();
    }

}


